|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectga.core.individual.population.KMeansClusterPopulation<T>
T - The generic type of individuals.public class KMeansClusterPopulation<T extends IClusterableIndividual<T>>
Implementation of a clusterable population that uses the
KMeansPlusPlusClusterer of Apache Commons Math.
| Field Summary | |
|---|---|
private boolean |
allowDuplicates
|
private int |
clusterCount
|
private org.apache.commons.math.stat.clustering.KMeansPlusPlusClusterer<T> |
clusterer
|
private java.util.List<org.apache.commons.math.stat.clustering.Cluster<T>> |
clusters
|
private IFitnessEvaluator<T> |
evaluator
|
private IIndividualFactory<T> |
factory
|
private int |
initIndividualCount
|
private static java.util.logging.Logger |
LOGGER
|
private static int |
MAX_ITERATIONS
|
private IndividualList<T> |
pop
|
private java.util.Random |
rnd
|
| Constructor Summary | |
|---|---|
KMeansClusterPopulation(IIndividualFactory<T> factory,
int initIndividualCount,
int clusterCount)
Creates a new clusterable population. |
|
KMeansClusterPopulation(IIndividualFactory<T> factory,
int initIndividualCount,
int clusterCount,
boolean allowDuplicates)
Creates a new clusterable population. |
|
| Method Summary | |
|---|---|
void |
addIndividual(T individual)
Adds an individual to the population. |
void |
addIndividuals(IndividualList<T> individuals)
Adds individuals to the population. |
void |
addIndividuals(T... individuals)
Adds individuals to the population. |
void |
assignFitness()
Assign fitness in all clusters. |
void |
assignFitness(T ind)
Searches for the cluster containing the given individual and assigns fitness to all individuals in the cluster. |
void |
clear()
Clears the population. |
boolean |
containsAny(IndividualList<T> list)
Determine if one of the individuals is contained in this list. |
void |
doClustering()
Divides the population into clusters. |
void |
evaluateAutomatic()
Evaluates all individiduals using the automatic evaluator. |
T |
getEliteIndividual()
Gets the elite individual, if elite strategy is used. |
int |
getEvaluatedIndividualCount()
Get the number of individuals that has been evaluated. |
T |
getFittestIndividual()
Gets the individual if the highest fitness. |
IndividualList<T> |
getIndividuals()
Getter for a list representation of the population. |
int |
getInitIndividualCount()
Get the number of initial individuals. |
T |
getRandomIndividualForEvaluation()
Randomly selects an individual to evaluate. |
T |
getRandomIndividualForSelection()
Randomly selects an individual to select. |
IndividualList<T> |
getUnevaluatedIndividuals()
Get all individuals that has not been evaluated yet. |
T |
getUnfittestIndividual()
Gets the individual if the lowest fitness. |
void |
initRandomly(IValidator<T> validator,
GAContext context)
Fill the population with random individuals. |
boolean |
isAllowDuplicates()
Determines if duplicates are allowed. |
boolean |
isEmpty()
Determines if the population is empty. |
java.util.Iterator<T> |
iterator()
|
void |
setEvaluator(IFitnessEvaluator<T> evaluator)
Sets the evaluator. |
void |
setInitIndividualCount(int individualCount)
Set the number of initial individuals. |
int |
size()
Returns the size of the population; the count of individuals. |
java.lang.String |
toClusterString()
Method that creates a string representation of the population, usually for debugging purposes. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final java.util.logging.Logger LOGGER
private static final int MAX_ITERATIONS
private final IndividualList<T extends IClusterableIndividual<T>> pop
private final IIndividualFactory<T extends IClusterableIndividual<T>> factory
private IFitnessEvaluator<T extends IClusterableIndividual<T>> evaluator
private boolean allowDuplicates
private final java.util.Random rnd
private int initIndividualCount
private int clusterCount
private java.util.List<org.apache.commons.math.stat.clustering.Cluster<T extends IClusterableIndividual<T>>> clusters
private final org.apache.commons.math.stat.clustering.KMeansPlusPlusClusterer<T extends IClusterableIndividual<T>> clusterer
| Constructor Detail |
|---|
public KMeansClusterPopulation(IIndividualFactory<T> factory,
int initIndividualCount,
int clusterCount)
factory - The individual factory.initIndividualCount - Init size of the population.clusterCount - Number of clusters to divide the population into.
public KMeansClusterPopulation(IIndividualFactory<T> factory,
int initIndividualCount,
int clusterCount,
boolean allowDuplicates)
factory - The individual factory.initIndividualCount - Init size of the population.clusterCount - Number of clusters to divide the population into.allowDuplicates - Allow duplicate individuals if true but prevent them
otherwise.| Method Detail |
|---|
public void setEvaluator(IFitnessEvaluator<T> evaluator)
IPopulation
setEvaluator in interface IPopulation<T extends IClusterableIndividual<T>>evaluator - The evaluator.
public void initRandomly(IValidator<T> validator,
GAContext context)
IPopulation
initRandomly in interface IPopulation<T extends IClusterableIndividual<T>>validator - The validator or null.context - The GA context.public IndividualList<T> getIndividuals()
IPopulation
getIndividuals in interface IPopulation<T extends IClusterableIndividual<T>>public void addIndividuals(T... individuals)
IPopulation
addIndividuals in interface IPopulation<T extends IClusterableIndividual<T>>individuals - Individuals to add.public void addIndividual(T individual)
IPopulation
addIndividual in interface IPopulation<T extends IClusterableIndividual<T>>individual - Individual to add.public void addIndividuals(IndividualList<T> individuals)
IPopulation
addIndividuals in interface IPopulation<T extends IClusterableIndividual<T>>individuals - Individuals to add.public void clear()
IPopulation
clear in interface IPopulation<T extends IClusterableIndividual<T>>public void evaluateAutomatic()
IPopulation
evaluateAutomatic in interface IPopulation<T extends IClusterableIndividual<T>>public java.lang.String toString()
toString in class java.lang.Objectpublic int size()
IPopulation
size in interface IPopulation<T extends IClusterableIndividual<T>>public T getUnfittestIndividual()
IPopulation
getUnfittestIndividual in interface IPopulation<T extends IClusterableIndividual<T>>public T getFittestIndividual()
IPopulation
getFittestIndividual in interface IPopulation<T extends IClusterableIndividual<T>>public T getEliteIndividual()
IPopulation
getEliteIndividual in interface IPopulation<T extends IClusterableIndividual<T>>null.public T getRandomIndividualForEvaluation()
IPopulation
getRandomIndividualForEvaluation in interface IPopulation<T extends IClusterableIndividual<T>>public T getRandomIndividualForSelection()
IPopulation
getRandomIndividualForSelection in interface IPopulation<T extends IClusterableIndividual<T>>public IndividualList<T> getUnevaluatedIndividuals()
IPopulation
getUnevaluatedIndividuals in interface IPopulation<T extends IClusterableIndividual<T>>public java.lang.String toClusterString()
public boolean isEmpty()
IPopulation
isEmpty in interface IPopulation<T extends IClusterableIndividual<T>>true if the population is empty.public boolean isAllowDuplicates()
IPopulation
isAllowDuplicates in interface IPopulation<T extends IClusterableIndividual<T>>true if duplicates are allowed.public int getEvaluatedIndividualCount()
IPopulation
getEvaluatedIndividualCount in interface IPopulation<T extends IClusterableIndividual<T>>public boolean containsAny(IndividualList<T> list)
IPopulation
containsAny in interface IPopulation<T extends IClusterableIndividual<T>>list - Individuals to look for.
true if this list contains any individual of the other
one.public java.util.Iterator<T> iterator()
iterator in interface IPopulation<T extends IClusterableIndividual<T>>iterator in interface java.lang.Iterable<T extends IClusterableIndividual<T>>public int getInitIndividualCount()
IPopulation
getInitIndividualCount in interface IPopulation<T extends IClusterableIndividual<T>>public void setInitIndividualCount(int individualCount)
IPopulation
setInitIndividualCount in interface IPopulation<T extends IClusterableIndividual<T>>individualCount - Number of init individuals.public void assignFitness(T ind)
IClusterPopulation
assignFitness in interface IClusterPopulation<T extends IClusterableIndividual<T>>ind - Individual that has fitness.public void assignFitness()
IClusterPopulation
assignFitness in interface IClusterPopulation<T extends IClusterableIndividual<T>>public void doClustering()
IClusterPopulation
doClustering in interface IClusterPopulation<T extends IClusterableIndividual<T>>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||